# -*- coding: utf-8 -*-
# @Time        : 2023/11/18
# @Author      : keyan.kalami
# @Email       : yclu@aioaiofm.ac.cn
# @File        : parse_traj.py
# @Project     : NovaPrograms
# @Description : 解析气象文件
from pysplit import generate_bulktraj
from datetime import datetime
import os
import pandas as pd
import json
import sqlite3
import requests
import pandas as pd
import numpy as np
from tqdm import tqdm
from datetime import datetime
import matplotlib.pyplot as plt 

import folium
from mpl_toolkits.basemap import Basemap

latitude=22.41902
longitude=113.6772

# 创建地图对象
map = folium.Map(location=[latitude, longitude], zoom_start=12)

# 添加标记点
folium.Marker([latitude, longitude], popup='Location Name').add_to(map)

# 添加散点图
data = [
    {'lat': 22.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 25.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 32.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 35.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 42.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 45.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 52.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 55.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 62.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 65.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 72.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 75.4, 'lon': 110.2, 'name': 'Point 2'},
    {'lat': 82.4, 'lon': 113.3, 'name': 'Point 1'},
    {'lat': 85.4, 'lon': 110.2, 'name': 'Point 2'},
    # 添加更多的散点数据...
]

for point in data:
    folium.Marker([point['lat'], point['lon']], popup=point['name']).add_to(map)

# 显示经纬度的横纵坐标
m = Basemap(projection='merc', llcrnrlat=map.get_bounds()[0][0], urcrnrlat=map.get_bounds()[1][0],
            llcrnrlon=map.get_bounds()[0][1], urcrnrlon=map.get_bounds()[1][1], lat_ts=20, resolution='c')
m.drawcoastlines()
m.drawcountries()
m.drawstates()
m.fillcontinents(color='#04BAE3',lake_color='#FFFFFF')
m.drawmapboundary(fill_color='#FFFFFF')

# 添加经纬度的标签
lat_min = map.get_bounds()[0][0]
lat_max = map.get_bounds()[1][0]
lon_min = map.get_bounds()[0][1]
lon_max = map.get_bounds()[1][1]

step_lat = round((lat_max - lat_min) / 10, 2)
step_lon = round((lon_max - lon_min) / 10, 2)

for lat in range(22, 85, 10):
    for lon in range(110,113,1):
        x, y = m(lon, lat)
        plt.text(x, y, '{} , {}'.format(lat, lon))

map.save('/root/Programs/NovaPrograms/datas/photo/GZ.pdf') #maptest.html改成你的文件


